﻿using System;
using System.Windows.Data;

using MissedMemo.MeatAndCheeseDisc.OrderEntry.OrderProcessing;


namespace MissedMemo.MeatAndCheeseDisc.OrderEntry
{
    public class OrderStateToDriverAssignmentEnabledConverter : IMultiValueConverter
    {
        public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            // Always test MultiValueConverter inputs for non-null
            // (to avoid crash bugs for views in the designer)
            if( values[0] is bool && values[1] is ProcessingState )
            {
                bool deliveryRequested = System.Convert.ToBoolean( values[0] );
                ProcessingState state = (ProcessingState)values[1];

                return deliveryRequested && ( state == ProcessingState.Ready || state == ProcessingState.OutForDelivery );
            }

            return false;
        }


        public object[] ConvertBack( object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }
}
